

def ge_circle(x=0,y=0,radius=10,*args)

	options = authoptions

	l = Hash.new
	l['id'] = 'circle'
	l['idTag'] = 'id'
	l['name'] = 'ge_circle'
	l['description'] = ''
	l['timeStamp'] = ' '
	l['timeSpanStart'] = ' '
	l['timeSpanStop'] = ' '
	l['visibility'] = 1
	l['lineColor'] = 'ffffffff'
	l['polyColor'] = 'ffffffff'
	l['lineWidth'] = 1.0
	l['msgToScreen'] = 0
	l['snippet'] = ' '
	l['altitude'] = 1.0
	l['divisions'] = 8
	l['altitudeMode'] = 'clampToGround'
	l['region'] = ' '
   
	l = parsepairs(options, args){ l }

	id_chars = "#{l['idTag']}=#{l['id']}"
	poly_id_chars = "#{l['idTag']}=poly_#{l['id']}"
	name_chars = "<name>#{l['name']}</name>"
	description_chars = "<description><![CDATA[ #{l['description']} ]]></description>"
	visibility_chars = "<visibility>#{l['visibility']}</visibility>"
	lineColor_chars = "<color>#{l['lineColor']}</color>"
	polyColor_chars = "<color>#{l['polyColor']}</color>"
	lineWidth_chars = "<width>#{l['lineWidth']}</width>"
	altitudeMode_chars = "<altitudeMode>#{l['altitudeMode']}</altitudeMode>"

	if l['region'] == ' '
		region_chars = '';
	else
		region_chars = "#{l['region']}"
	end

	if l['snippet'] == ' '
			snippet_chars = ''
	else
			snippet_chars = "<Snippet>#{l['snippet']}</Snippet>"   
	end
		 

	if l['timeStamp'] == ' '
			timeStamp_chars = '';
	else
			timeStamp_chars = "<TimeStamp><when>#{l['timeStamp']}</when></TimeStamp>"
	end

	if l['timeSpanStart'] == ' '
			timeSpan_chars = '';
	else
			if l['timeSpanStop'] == ' ' 
					timeSpan_chars = "<TimeSpan><begin>#{l['timeSpanStart']}</begin></TimeSpan>"
			else
					timeSpan_chars = "<TimeSpan><begin>#{l['timeSpanStart']}</begin><end>#{l['timeSpanStop']}</end></TimeSpan>"  
			end
					
	end
 
	#l['radius'] = km2deg(l['radius']/1000);
	#l['divisions'] = 2 .^ l['divisions'];
	l['angle_division'] = 360.0 / l['divisions'];
 
	header = []
	header << "<Placemark #{id_chars}>"
	header << "		#{name_chars}"
	header << "		#{timeStamp_chars}"
	header << "		#{timeSpan_chars}"
	header << "		#{visibility_chars}"
	header << "		#{snippet_chars}"
	header << "		#{description_chars}"
	header << "		#{region_chars}"
	header << "		<Style>"
	header << "			<LineStyle>"
	header << "			#{lineColor_chars}"
	header << "			#{lineWidth_chars}"
	header << "			</LineStyle>"
	header << "			<PolyStyle>"
	header << "			#{polyColor_chars}"
	header << "			</PolyStyle>"
	header << "		</Style>"
	header << "		<Polygon #{poly_id_chars}>"
	header << "			#{name_chars}"
	header << "			#{altitudeMode_chars}"
	header << "			<outerBoundaryIs>"
	header << "			<LinearRing>"
	header << "				altitudeMode_chars}"
	header << "				<coordinates>"


=begin
		coordinates = '';
		for i = divisions:-1:0
		  angle = angle_division * i;
			[xS, yS] = vectorsplit( angle, radius );
      [a,b] = track1(Y,X,angle,radius,[],[],2);
      ringlat(i+1)=a(2);ringlon(i+1)=b(2);
			%coordinates = [coordinates, sprintf('%.6f,%.6f,%.6f ', X+xS, Y+yS, altitude)];
		  coordinates = [coordinates, sprintf('%.6f,%.6f,%.6f ', b(2), a(2), altitude)];
		end
=end

	coordinates = ''
	l['divisions'].downto(0){ |i|
		angle = l['angle_division'] * i
		

	}


		
	footer = []
	footer << "				</coordinates>"
	footer << "			</LinearRing>"
	footer << "			</outerBoundaryIs>"
	footer << "		</Polygon>"
	footer << "</Placemark>"
	
	
	output = "#{header}"
	output << "#{footer}"
	
	return output


end

